var { randomUtils, clickUtils, logUtils } = require("../../utils/index");
var { App } = require("../../base/index");
var pointMap = require("./pointMap");
var inTask = require("./inTask");
var aEat = require("./aEat");
var aRead = require("./aRead");
var aTreasure = require("./aTreasure");

var wuKong = new App("有柿", {
  interval: 10 * 60,
  maxRunTCount: 3,
  maxOpenCount: 30,
});

wuKong.runTest = function (count) {
  logUtils.info(this.name, "runTest", count, "/", this.maxRunTCount);
  if (count == 0) {
    sleep(randomUtils.getRandom(10, 30, 1000));
    return;
  }
  if (count == 1) {
    if (randomUtils.possible(90, 100)) {
      clickUtils.clickPointMap(pointMap.首页.视频);
    } else if (randomUtils.possible(70, 90)) {
      clickUtils.clickPointMap(pointMap.首页.我的);
    } else {
      clickUtils.clickPointMap(pointMap.首页.任务);
    }
    sleep(randomUtils.getRandom(10, 30, 1000));
    return;
  }
  if (count == 2) {
    clickUtils.clickPointMap(pointMap.首页.视频);
    sleep(randomUtils.getRandom(10, 30, 1000));
  }
};
wuKong.run = function () {
  aRead.flow();
  if (randomUtils.possible(90, 100)) {
    clickUtils.clickPointMap(pointMap.首页.我的);
    sleep(randomUtils.getRandom(10, 30, 1000));
    this.openCount--;
  } else {
    clickUtils.clickPointMap(pointMap.首页.任务);
    sleep(randomUtils.getRandom(10, 15, 1000));
    aTreasure.flow();
    inTask.init();
    sleep(randomUtils.getRandom(5, 10, 1000));
    aEat.flow();
  }
};

module.exports = wuKong;
